{extend name="public/layout" /}
{block name="head"}
<style>
  body {
    width: 100%;
    height: 100vh;
    margin: 0 auto;
    background-image: url('/static/system/images/login/{:rand(101,120)}.jpg');
    background-repeat: no-repeat;
    background-size: cover;
    overflow: hidden;
  }

  .wrapper {
    position: relative;
  }

  .login {
    display: flex !important;
    min-height: 100vh;
    align-items: center !important;
    justify-content: center !important;
  }

  .login-center {
    background: #fff;
    min-width: 38.25rem;
    padding: 2.14286em 3.57143em;
    border-radius: 5px;
    margin: 2.85714em 0;
  }

  .login-header {
    margin-bottom: 1.5rem !important;
    font-size: 32px;
  }

  .login-center .has-feedback.feedback-left .form-control {
    padding-left: 38px;
    padding-right: 12px;
  }

  .login-center .has-feedback.feedback-left .form-control-feedback {
    left: 0;
    right: auto;
    width: 38px;
    height: 38px;
    line-height: 38px;
    z-index: 4;
    color: #dcdcdc;
  }

  .login-center .has-feedback.feedback-left.row .form-control-feedback {
    left: 15px;
  }
</style>
{/block}
{block name="body"}

<body>
  <div class="row wrapper">
    <div class="login">
      <div class="login-center">
        <div class="login-header text-center">
          用户登录
        </div>
        <form id="form" method="post">
          <div class="form-group has-feedback feedback-left">
            <input type="text" placeholder="请输入您的账户名/手机号" class="form-control" id="account" />
            <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
          </div>
          <div class="form-group has-feedback feedback-left">
            <input type="password" placeholder="请输入密码" class="form-control" id="password" />
            <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
          </div>
          <div class="form-group has-feedback feedback-left row">
            <div class="col-xs-7">
              <input type="text" id="captcha_code" class="form-control" placeholder="验证码">
              <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
            </div>
            <div class="col-xs-5">
              <img src="{:captcha_src()}" id="captcha" class="pull-right" style="cursor: pointer;"
                onclick="this.src=this.src+'?d='+Math.random();" title="点击刷新">
            </div>
          </div>
          <div class="form-group">
            <button class="btn btn-block btn-primary" id="login-btn" type="button">立即登录</button>
          </div>
        </form>
      </div>
    </div>
  </div>
  <script>
    $(function () {
      $('#login-btn').on('click', function () {
        var account = $("#account").val();
        var password = $("#password").val();
        var captcha_code = $('#captcha_code').val();
        if (valid.isEmpty(account)) {
          layer.msg('用户名不能为空');
          return false;
        }
        if (valid.isEmpty(password)) {
          layer.msg('密码不能为空');
          return false;
        }
        if (valid.isEmpty(captcha_code)) {
          layer.msg('验证码不能为空');
          return false;
        }
        helper.getAjax({
          url: "login.html",
          data: { account: account, password: password, captcha_code: captcha_code },
          success: function (res) {
            $('#captcha').click();
            if (res.code == 1) {
              location.href = '/system/index/index.html';
            } else {
              layer.msg(res.msg);
            }
          }
        });
      });
      $(document).keyup(function (event) {
        if (event.keyCode == 13) {
          $("#login-btn").trigger("click");
        }
      });
    });
  </script>
</body>
{/block}